package com.ws.service.impl;

import java.util.ArrayList;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Component;

import com.ws.dao.AdminDao;
import com.ws.entity.Admin;
import com.ws.service.LoginService;

@Component("adminLoginServiceImpl")
public class AdminLoginServiceImpl implements LoginService {
	
	private AdminDao adminDao;
	
	@Resource(name="adminDaoImpl")
	public void setAdminDao(AdminDao adminDao) {
		this.adminDao = adminDao;
	}

	public String doLogin(String username,String password) {
		List<Admin> adminList=new ArrayList<Admin>();
		adminList=adminDao.getObjectList();
		for(int i=0;i<adminList.size();i++){
			if(username.equals(adminList.get(i).getAdminName()) && 
					password.equals(adminList.get(i).getAdminPwd())){
				return "success";
			}
		}
		return "error";
	}

}
